package com.frabo.watchadoin;

import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.frabo.watchadoin.model.Doing;

public class MainActivity extends Activity
{
	private WatchaDoinApplication app;
	private EditText nameDoingEditText;
	ViewGroup rootLayout;

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main, menu);
		return true;
	}

	/**
	 * Called when the activity is first created.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		app = WatchaDoinApplication.getInstance();

		// Get components
		nameDoingEditText = (EditText) findViewById(R.id.name_doing_edit_text);

		// Set font
		rootLayout = (ViewGroup) findViewById(R.id.main_activity_root_layout);
		app.setFont(rootLayout, app.avenirFont);
	}

	public void onStartClicked(View v)
	{
		// Create the new doing object, save it in app object, go to doing
		// activity
		// Toast.makeText(this, nameDoingEditText.getText(),
		// Toast.LENGTH_LONG).show();
		app.currentDoing = new Doing(nameDoingEditText.getText().toString(), new Date());
		Intent intent = new Intent(this, DoingActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
		startActivity(intent);
	}
}
